﻿<?php
include_once(dirname(__FILE__).'/../class/T1Factory.class.php');
include_once(dirname(__FILE__).'/../class/T2Factory.class.php');

$db = Db::getInstance();
$sql = "select blueprintTypeID,techLevel from invblueprinttypes where productTypeID = ".$_GET['id'].";";
$db->db_query($sql,'callback');

function callback($query_result){
    $db = Db::getInstance();
    if(!$db->getRows())
        die(json_encode('FALSE'));
    if($query_result[0]->techLevel == 1) // t1 科技
    {
        $t1_factory = new T1Factory();
        $product = $t1_factory->createProduct($_GET['id']);
        die($product->toJson());
    }
    else if($query_result[0]->techLevel == 2) // t2 科技
    {
        $t2_factory = new T2Factory();
        $product = $t2_factory->createProduct($_GET['id']);
        die($product->toJson());
    }
}
?>
